<script setup lang="ts">
import { getStoreDetail } from '~/api/index'
import { getTalkDetail, getUserInfo } from '~/pages/template/tools'

const talkDetail = ref<any>()
const userDetail = ref<any>()
const storeDetail = ref<any>()
async function init() {
  if (getTalkDetail()) {
    talkDetail.value = getTalkDetail()
    // 做一个简单判断，如果当前是一个买家 那么和他聊天的一定是卖家
    if (userDetail.value.___role === 'BUYER') {
      const res = await getStoreDetail(talkDetail.value.userId)
      if (res.data.success)
        storeDetail.value = res.data.result
    }
  }
}

onMounted(() => {
  if (getUserInfo())
    userDetail.value = getUserInfo()

  init()
})
</script>

<template>
  <div v-if="storeDetail" p-16px>
    <div flex flex-a-c pb-12px>
      <div color-warmGray>
        店铺名称：
      </div>
      <div>{{ storeDetail.storeName }}</div>
    </div>
    <div flex flex-a-c pb-12px>
      <div color-warmGray>
        联系电话：
      </div>
      <div>{{ storeDetail.storeMobile }}</div>
    </div>
    <div mb-10px border-b pt-10px />
    <div mt-20px flex flex-a-c pb-12px>
      <div color-warmGray>
        评分明细：
      </div>
      <div flex flex-col flex-a-c>
        <div pb-8px color-warmgray>
          用户评价：<span color-red-5>{{ storeDetail.descriptionScore }}</span>
        </div>
        <div pb-8px color-warmgray>
          物流履约：<span color-red-5>{{ storeDetail.deliveryScore }}</span>
        </div>
        <div pb-8px color-warmgray>
          售后服务：<span color-red-5>{{ storeDetail.serviceScore }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>

</style>
